home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / include / Ecore_Con.h < prev    next >
Encoding:
C/C++ Source or Header  |  2006-01-09  |  5.8 KB  |  181 lines

  1. #ifndef _ECORE_CON_H
  2. #define _ECORE_CON_H
  3.  
  4. #ifdef EAPI
  5. #undef EAPI
  6. #endif
  7. #ifdef WIN32
  8. # ifdef BUILDING_DLL
  9. #  define EAPI __declspec(dllexport)
  10. # else
  11. #  define EAPI __declspec(dllimport)
  12. # endif
  13. #else
  14. # ifdef __GNUC__
  15. #  if __GNUC__ >= 4
  16. #   define EAPI __attribute__ ((visibility("default")))
  17. #  else
  18. #   define EAPI
  19. #  endif
  20. # else
  21. #  define EAPI
  22. # endif
  23. #endif
  24.  
  25. #include <netdb.h>
  26.  
  27. /**
  28.  * @file Ecore_Con.h
  29.  * @brief Sockets functions.
  30.  *
  31.  * The Ecore Connection Library ( @c Ecore_Con ) provides simple mechanisms
  32.  * for communications between programs using reliable sockets.  It saves
  33.  * the programmer from having to worry about file descripters and waiting
  34.  * for incoming connections.
  35.  *
  36.  * There are two main objects in the @c Ecore_Con library: the @c
  37.  * Ecore_Con_Server and the @c Ecore_Con_Client.
  38.  *
  39.  * The @c Ecore_Con_Server represents a server to connect to.  It is
  40.  * represents a server that can be connected to.  It is used regardless
  41.  * of whether the program is acting as a server or client itself.
  42.  *
  43.  * To create a listening server, call @c ecore_con_server_add().
  44.  *
  45.  * To connect to a server, call @c ecore_con_server_connect().  Data can
  46.  * then be sent to the server using the @c ecore_con_server_send().
  47.  * 
  48.  * Whenever a client connection is made to an @c Ecore_Con_Server, a
  49.  * @c ECORE_CON_CLIENT_ADD event is emitted.  Any event callbacks that are
  50.  * called receive a @c Ecore_Con_Client object, which represents a
  51.  * connection that that particular client.
  52.  *
  53.  * Functions are described in the following groupings:
  54.  * @li @ref Ecore_Con_Lib_Group
  55.  * @li @ref Ecore_Con_Server_Group
  56.  * @li @ref Ecore_Con_Client_Group
  57.  */
  58.  
  59. #ifdef __cplusplus
  60. extern "C" {
  61. #endif
  62.    
  63. #ifndef _ECORE_CON_PRIVATE_H
  64.    typedef void Ecore_Con_Server; /**< A connection handle */
  65.    typedef void Ecore_Con_Client; /**< A connection handle */
  66.    typedef void Ecore_Con_Url;
  67.    
  68.    typedef enum _Ecore_Con_Type
  69.      {
  70.       ECORE_CON_LOCAL_USER,
  71.       ECORE_CON_LOCAL_SYSTEM,
  72.       ECORE_CON_REMOTE_SYSTEM,
  73.       ECORE_CON_USE_SSL = 16
  74.      } Ecore_Con_Type;
  75.    
  76. #endif
  77.    
  78.    typedef struct _Ecore_Con_Event_Client_Add  Ecore_Con_Event_Client_Add;
  79.    typedef struct _Ecore_Con_Event_Client_Del  Ecore_Con_Event_Client_Del;
  80.    typedef struct _Ecore_Con_Event_Server_Add  Ecore_Con_Event_Server_Add;
  81.    typedef struct _Ecore_Con_Event_Server_Del  Ecore_Con_Event_Server_Del;
  82.    typedef struct _Ecore_Con_Event_Client_Data Ecore_Con_Event_Client_Data;
  83.    typedef struct _Ecore_Con_Event_Server_Data Ecore_Con_Event_Server_Data;
  84.    typedef struct _Ecore_Con_Event_Url_Data Ecore_Con_Event_Url_Data;
  85.    typedef struct _Ecore_Con_Event_Url_Complete Ecore_Con_Event_Url_Complete;
  86.  
  87.    struct _Ecore_Con_Event_Client_Add
  88.      {
  89.     Ecore_Con_Client *client;
  90.      };
  91.  
  92.    struct _Ecore_Con_Event_Client_Del
  93.      {
  94.     Ecore_Con_Client *client;
  95.      };
  96.  
  97.    struct _Ecore_Con_Event_Server_Add
  98.      {
  99.     Ecore_Con_Server *server;
  100.      };
  101.  
  102.    struct _Ecore_Con_Event_Server_Del
  103.      {
  104.     Ecore_Con_Server *server;
  105.      };
  106.    
  107.    struct _Ecore_Con_Event_Client_Data
  108.      {
  109.     Ecore_Con_Client *client;
  110.     void             *data;
  111.     int               size;
  112.      };
  113.    
  114.    struct _Ecore_Con_Event_Server_Data
  115.      {
  116.     Ecore_Con_Server *server;
  117.     void             *data;
  118.     int               size;
  119.      };
  120.    
  121.    struct _Ecore_Con_Event_Url_Data
  122.      {
  123.     Ecore_Con_Url    *url_con;
  124.     void             *data;
  125.     int               size;
  126.      };
  127.      
  128.    struct _Ecore_Con_Event_Url_Complete
  129.      {
  130.     Ecore_Con_Url    *url_con;
  131.     int               status;
  132.      };
  133.      
  134.    EAPI extern int ECORE_CON_EVENT_CLIENT_ADD;
  135.    EAPI extern int ECORE_CON_EVENT_CLIENT_DEL;
  136.    EAPI extern int ECORE_CON_EVENT_SERVER_ADD;
  137.    EAPI extern int ECORE_CON_EVENT_SERVER_DEL;
  138.    EAPI extern int ECORE_CON_EVENT_CLIENT_DATA;
  139.    EAPI extern int ECORE_CON_EVENT_SERVER_DATA;
  140.    EAPI extern int ECORE_CON_EVENT_URL_DATA;
  141.    EAPI extern int ECORE_CON_EVENT_URL_COMPLETE;
  142.    
  143.    EAPI int               ecore_con_init(void);
  144.    EAPI int               ecore_con_shutdown(void);
  145.    
  146.    EAPI Ecore_Con_Server *ecore_con_server_add(Ecore_Con_Type type, const char *name, int port, const void *data);
  147.    
  148.    EAPI Ecore_Con_Server *ecore_con_server_connect(Ecore_Con_Type type, const char *name, int port, const void *data);
  149.    EAPI void             *ecore_con_server_del(Ecore_Con_Server *svr);
  150.    EAPI void             *ecore_con_server_data_get(Ecore_Con_Server *svr);
  151.    EAPI int               ecore_con_server_connected_get(Ecore_Con_Server *svr);
  152.    EAPI int               ecore_con_server_send(Ecore_Con_Server *svr, void *data, int size);
  153.    EAPI void              ecore_con_server_client_limit_set(Ecore_Con_Server *svr, int client_limit, char reject_excess_clients);
  154.    EAPI void              ecore_con_server_disown(Ecore_Con_Server *svr);
  155.    
  156.    EAPI int               ecore_con_client_send(Ecore_Con_Client *cl, void *data, int size);
  157.    EAPI Ecore_Con_Server *ecore_con_client_server_get(Ecore_Con_Client *cl);
  158.    EAPI void             *ecore_con_client_del(Ecore_Con_Client *cl);
  159.    EAPI void              ecore_con_client_data_set(Ecore_Con_Client *cl, const void *data);
  160.    EAPI void             *ecore_con_client_data_get(Ecore_Con_Client *cl);
  161.    
  162.    EAPI int               ecore_con_ssl_available_get(void);
  163.  
  164.    EAPI int               ecore_con_url_init(void);
  165.    EAPI int               ecore_con_url_shutdown(void);
  166.    EAPI Ecore_Con_Url    *ecore_con_url_new(const char *url);
  167.    EAPI void              ecore_con_url_destroy(Ecore_Con_Url *url_con);
  168.    EAPI int               ecore_con_url_url_set(Ecore_Con_Url *url_con, const char *url);
  169.    EAPI int               ecore_con_url_send(Ecore_Con_Url *url_con, void *data, size_t length, char *content_type);
  170.  
  171.    EAPI int               ecore_con_dns_lookup(const char *name,
  172.                            void (*done_cb)(void *data, struct hostent *hostent),
  173.                            void *data);
  174.  
  175.  
  176. #ifdef __cplusplus
  177. }
  178. #endif
  179.  
  180. #endif
  181.